package com.andy.qhb.action;

import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.springframework.stereotype.Component;

import com.andy.qhb.dao.DaoUtils;
import com.andy.qhb.entity.UsrGroups;
import com.andy.qhb.game.GameUser;
import com.andy.qhb.game.Global;
import com.andy.qhb.utils.GmAction;
import com.andy.qhb.utils.SendUtil;
import com.andy.qhb.websocket.MySocketSession;

/**
 * 新建群
 * @author cuiwm
 *
 */
@Component(GmAction.ACTION_PREFIX+GmAction.ACTION_113)
public class Action113 implements IWebAction{

	@Override
	public void doAction(MySocketSession myWebSocket, Map<String, Object> data) {
		
		GameUser user = myWebSocket.getUser();
		String title = MapUtils.getString(data, "title");
		
		UsrGroups group = new UsrGroups();
		group.setName(title);
		group.setCid(user.getId());
		group.setGuids(user.getId()+",");
		
		DaoUtils.insert(group);
		Global.addGroup(group );
		
		SendUtil.send113(myWebSocket, group);
		
	}

	
	
	
}
